package com.weitu.archives.personArchives.service.impl;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Demo
{
    public static void main(String[] args)
    {
        /** 要读取的文件路径，可以自己修改成自己的路径 */
        String url = "C:/Users/smp/Desktop/Test.txt";
        /**
         * 读取文件数据
         */
        File file = new File(url);
        if (!file.exists() || file.isDirectory())
        {
            System.out.println("文件不存在！");
            return;
        }
        StringBuffer sb = null;
        BufferedReader br;
        try
        {
            br = new BufferedReader(new FileReader(file));
            String temp = null;
            sb = new StringBuffer();
            temp = br.readLine();
            while (temp != null)
            {
                sb.append(temp + "\r");
                temp = br.readLine();
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        /** 读取的文件内容 */
        String info = sb.toString();
        int num = 0;
        for (int i = 0; i < info.length(); i++)
        {

                num++;

        }
        System.out.println("文件中A的个数：" + num);
    }
}
